using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Game;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay
{
    public class UIN_FormationPopupHero : UIBaseNode
    {

        #region Template Generate,don't modify
        protected partial class UIB_UIN_FormationPopupHero
        {
            #region ObjectBinding Generate 
            public GameObject commonHeroHead { protected set; get; }
            public GameObject tagcaptain { protected set; get; }
            public IQIGame.Onigao.Framework.ExButton heroMould { protected set; get; }
            public GameObject emptyRoot { protected set; get; }
            public virtual void InitBinding(ObjectBinding __binding)
            {
                __binding.TryGetVariableValue<UnityEngine.GameObject>("commonHeroHead", out var __tbv0);
                this.commonHeroHead = __tbv0;
                __binding.TryGetVariableValue<UnityEngine.GameObject>("tagcaptain", out var __tbv1);
                this.tagcaptain = __tbv1;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExButton>("heroMould", out var __tbv2);
                this.heroMould = __tbv2;
                __binding.TryGetVariableValue<UnityEngine.GameObject>("emptyRoot", out var __tbv3);
                this.emptyRoot = __tbv3;
            }

            #endregion ObjectBinding Generate 
        }
        #endregion Template Generate,don't modify

        #region fields & properties
        UIN_CommonHeroHead heroHead = null;

        protected UIB_UIN_FormationPopupHero ui { get; set; }
        #endregion

        protected override void BeforeInit()
        {
            ui = new UIB_UIN_FormationPopupHero();
            ui.InitBinding(this.csObjBind);
        }

        protected override void OnInit()
        {

            var cvsGroup = this.ui.commonHeroHead.GetOrAdd<CanvasGroup>();
            cvsGroup.blocksRaycasts = false;

            this.heroHead = this.InitChildNode<UIN_CommonHeroHead>(this.ui.commonHeroHead);
            this.ui.tagcaptain.SetActive(false);
            this.ui.emptyRoot.SetActive(false);
        }

        protected override void OnShow()
        {

        }

        protected override void OnHide()
        {

        }

        protected override void OnDispose()
        {
        }

        public void Show(FormationHeroData data)
        {
            this.Show();
            this.ui.tagcaptain.SetActive(data.isCaptain);
            var heroData = data.heroData;
            this.heroHead.Show(heroData);
            this.ui.emptyRoot.SetActive(heroData == null);
        }
    }
}
